import request from "./request.js";

// 登陆
export function login(data) {
    return request({
        url: '/api/login',
        method: 'post',
        data
    })
}

// 注册
export function register(data) {
    return request({
        url: '/api/register',
        method: 'post',
        data
    })
}

// 比赛列表页面获取所有比赛信息
export function games(data) {
    return request({
        url: `/api/games/${data.page}/${data.asknumber}`,
        method: 'get',
        data
    })
}
// competitionList页面获取所有比赛信息
export function competitionList(data) {
    return request({
        url: `/api/games/${data}/9`,
        method: 'get',
        data
    })
}
// 首页热门比赛推荐页面查看所有比赛
export function HomeGames(data) {
    return request({
        url: `/api/games/${data}/3`,
        method: 'get',
        data
    })
}
// 后台查看所有比赛
export function BackGames(data) {
    return request({
        url: `/api/games/${data}/10`,
        method: 'get',
        data
    })
}

// 超管根据gameID删除比赛
export function deleteGame(data){
    return request({
        url: `api/games/delete/${data}`,
        method: 'post',
        data
    })
}

//获取裁判比赛下的所有小组
export function getInfoList(data){
    return request({
        url: 'api/games/getInfoList',
        method: 'post',
        data
    })
}

// 报名1,这个接口是先在后端创建好groupID
export function signUp(data) {
    return request({
        url: `api/games/signup/${data}`,
        method: 'post',
        data
    })
}
// 报名2，这个接口是在创建groupID后开始正式创建小组
export function addGruop(data){
    return request({
        url: 'api/groups/add',
        method: 'post',
        data
    })
}


// 获取自己参与的小组信息
export function getOwnGroupList(){
    return request({
        url: 'api/groups/getOwnGroupList',
        method: 'get',
    })
}

// 获取比赛小组信息
export function getgroups(data) {
    return request({
        url: `api/groups/getInfo/${data}`,
        method: 'post',
        data
    })
}

// 根据groupID获取小组成员
export function getGroupManInfo(data){
    return request({
        url: `api/groups/getGroupManInfo/${data}`,
        method: 'post',
        data
    })
}

// 修改小组成员信息
export function updateGroupPartner(data){
    return request({
        url: 'api/groups/updateGroupPartner',
        method: 'post',
        data
    })
}

// 添加小组成员
export function addGroupPartner(data){
    return request({
        url: 'api/groups/addGroupPartner',
        method: 'post',
        data
    })
}

// 删除小组成员信息
export function deleteGroupPartner(data){
    return request({
        url: 'api/groups/deleteGroupPartner',
        method: 'post',
        data
    })
}

// 根据groupID获取作品名称
export function getWorkInfo(data){
    return request({
        url: `api/works/getWorkInfo/${data}`,
        method: 'post',
        data
    })
}

// 根据groupID修改小组基本信息
export function updateBasicInformation(data){
    return request({
        url: 'api/groups/updateBasicInformation',
        method: 'post',
        data
    })
}

// 根据groupID在作品提交后更新作品信息
export function renewWork(data){
    return request({
        url: 'api/works/update',
        method: 'post',
        data
    })
}

// 根据groupID获取作品状态（是否上传）
export function getWorkStatus(data){
    return request({
        url: 'api/works/getWorkStatus',
        method: 'post',
        data
    })
}

// 根据groupID给作品打分
export function judgeScore(data){
    return request({
        url: 'api/scores/judge',
        method: 'post',
        data
    })
}


// 根据id删除老师
export function deleteTeacher(data){
    return request({
        url: `api/groups/deleteTeacher/${data}`,
        method: 'post',
        data
    })
}

// 根据id添加老师
export function addTeacher(data){
    return request({
        url: 'api/groups/addTeacher',
        method: 'post',
        data
    })
}

// 修改老师信息
export function updateTeacherInfo(data){
    return request({
        url: 'api/groups/updateTeacherInfo',
        method: 'post',
        data
    })
}


// 获取小组指导老师
export function getGroupTeacherInfo(data){
    return request({
        url: `api/groups/getGroupTeacherInfo/${data}`,
        method: 'post',
        data
    })
}


// 根据gameID获取比赛小组人数限制
export function updateLimit(data) {
    return request({
        url: 'api/games/updateLimit/4/6',
        method: 'post',
        data
    })
}

// 跟据gamesID获取比赛裁判
export function getJudgeListInfo(data){
    return request({
        url: `api/games/getjudgeListInfo/${data}`,
        method: 'post'
    })
}

//  删除随机裁判
export function deleteRandomJudge(data){
    return request({
        url: 'api/games/deleteRandomJudge',
        method: 'post',
        data
    })
}

// 根据AdminID获取发布者的名字
export function getAdminNamebyId(data) {
    return request({
        url: 'api/games/getAdminNamebyId/3',
        method: 'post',
        data
    })
}

// 更具gameID获取groupID
export function getGroupBygameID(data){
    return request({
        url: `api/games/getGroupBygmID/${data}`,
        method: 'post',
        data
    })
}

//  根据gameID获取比赛报名人数
export function count(data) {
    return request({
        url: 'api/games/count/5',
        method: 'post',
        data
    })
}

// 跟具比赛ID获取比赛详细信息
export function getGamebyId(data){
    return request({
        url: `api/games/getGamebyId/${data}`,
        method: 'post',
        data
    })
}

// 管理员添加裁判账号
export function addJudges(data){
    return request({
        url: `api/games/randonJudge/${data.num}/${data.gameID}`,
        method: 'post',
        data
    })
}

// 发布比赛
export function addGame(data){
    return request({
        url: 'api/games/add',
        method: 'post',
        data
    })
}

// 添加文章
export function addArticle(data){
    return request({
        url: 'api/ariticle/addArticle',
        method: 'post',
        data
    })
}

// 获取文章
export function getAriticle(data){
    return request({
        url: `api/ariticle/${data.pages}/${data.number}/${data.classification}`,
        method: 'get',
        params: data
    })
}

// 根据id删除文章
export function deleteArtice(data){
    return request({
        url: 'api/ariticle/deleteArticle',
        method: 'post',
        data
    })
}

// 根据ID获取单个文章
export function getArticleByID(data){
    return request({
        url: 'api/ariticle/getArticleByID',
        method: 'post',
        data
    })
}

// 下载裁判execl
export function downloadJudge(data){
    return request({
        url: 'api/excel/downloadJudge',
        method: 'post',
        data
    })
}

// 获取自己发布的比赛
export function getOwnGameList(){
    return request({
        url: 'api/games/getOwnGameList',
        method: 'post',
    })
}

// 获取排名
export function getRanking(data){
    return request({
        url: 'api/scores/getAverageScoreAndRanking',
        method: 'post',
        data
    })
}

// 获取队伍作品的得分详情
export function getJudgeLine(data){
    return request({
        url: 'api/scores/getJudgeLine',
        method: 'post',
        data
    })
}

//获取排名列表
export function getRankList(data){
    return request({
        url: 'api/scores/getRankList',
        method: 'post',
        data
    })
}

//修改基本信息
export function changeUser(data){
    return request({
        url: 'api/users/updateUserInfo',
        method: 'post',
        data
    })
}

// 修改密码
export function changePassword(data){
    return request({
        url: 'api/users/changePassword',
        method: 'post',
        data
    })
}

//通过用户id获取用户信息
export function getUserInformation(data){
    return request({
        url: `api/users/${data}`,
        method: 'get',
        params: {
            data
        }
    })
}



// 通过gameID导出所有小组信息
export function downloadGroups(data){
    return request({
        url: 'api/excel/downloadGroups',
        method: 'post',
        data
    })
}

// 导出排名表格
export function downloadRanks(data){
    return request({
        url: 'api/excel/downloadRanks',
        method: 'post',
        data
    })
}


export default {
    login,
    register,
    games,
    signUp,
    addGruop,
    getAdminNamebyId,
    getgroups,
    count,
    getGroupManInfo,
    getGroupTeacherInfo,
    getWorkInfo,
    addJudges,
    getJudgeListInfo,
    deleteRandomJudge,
    updateBasicInformation,
    deleteTeacher,
    addTeacher,
    updateTeacherInfo,
    getOwnGroupList,
    addGame,
    HomeGames,
    BackGames,
    getGamebyId,
    updateGroupPartner,
    deleteGroupPartner,
    addGroupPartner,
    getWorkStatus,
    getInfoList,
    addArticle,
    getAriticle,
    getArticleByID,
    renewWork,
    judgeScore,
    deleteArtice,
    deleteGame,
    getGroupBygameID,
    competitionList,
    downloadJudge,
    getOwnGameList,
    getRanking,
    changePassword,
    changeUser,
    getUserInformation,
    downloadGroups,
    downloadRanks,
    getRankList,
    getJudgeLine
}
